package org.lgl.order.controller;

import org.lgl.common.exception.GlobalException;
import org.lgl.common.result.CodeMsg;
import org.lgl.common.result.Result;
import org.lgl.goods.api.TestApi;
import org.lgl.goods.model.TestVO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lgl
 * @date 2022/2/24 17:55
 */
@RestController
@RequestMapping("/order")
public class OrderServerController {
    private final TestApi api;

    public OrderServerController(TestApi api) {
        this.api = api;
    }

    @RequestMapping("/get/{id}")
    public Result<TestVO> testGet(@PathVariable(name = "id") Long id) {
        if (id > 10) {
            throw new GlobalException(CodeMsg.GOODS_ERROR);
        }
        return api.testGet(id);
    }
}
